import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL), // 使用何种模式 hash history
  // process.env.VUE_APP_BASE_UBL Vue2 webpack环境下，取环境变量
  // import.meta.env.BASE_URL Vue3 vite取环境变量
  routes: [
    {
      path: '/',
      name: 'home',
      component: () => import('@/views/home/index.vue') // vite组件必须跟上.vue组件，按需导入
    },
    {
      path: '/login/:id?',
      name: 'login',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('@/views/login/index.vue')
    }
  ]
})

export default router
